﻿// owner 蒋家伟

#pragma once
#include "IExternalDataComponent.h"

// 序列化
#include "DBSchemaObject.h"
#include "ObjectReflectDeclare.h"
#include "DataSerializeDefine.h"

// jsdk
#include "IExternalData.h"

namespace jsdk
{
    // 类别描述 : 外部数据组件
    class ExternalDataComponent: public DBSchemaObject, public IExternalDataComponent
    {
    public:
        OBJECT_SERIALIZE_DECLARE_DERIVED2(jsdk, ExternalDataComponent, L"{338C178C-5280-4064-BFB6-76BDEACB3B50}", DBSchemaObject, IExternalDataComponent)
            DATA_UMAP(std::wstring, OwnerPtr<IExternalData>, keyToExternalDataUMap)
    public:
        void setOwnerElement(IElement* pOwnerElement);
        static OwnerPtr<ExternalDataComponent> create();
        bool registerExternalData(const std::wstring& key, OwnerPtr<IExternalData> opExternalData);

    private:
        virtual const IExternalData* getExternalData(const std::wstring& externalDataKey) const override;
        virtual IExternalData* getExternalData(const std::wstring& externalDataKey) override;
    };
}
